﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Skywave.Data
{
    [DataContract]
    public class ChartDataGeneratorAggregate : EventArgs
    {
        public ChartDataGeneratorAggregate()
        {
            JoinClauses = new List<string>();
            Function = ChartDataGeneratorAggregateFunctions.Count;
            DesignSettings = new Dictionary<string, string>();
            Columns = new List<ChartDataGeneratorAggregateColumn>();
        }
        //
        public string SqlRandomKey { get; set; }
        public int SqlUniqueId { get; set; }
        public string SqlInitialization { get; set; }
        public string SqlTempTableName_Filter { get; set; }
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public int DesignId { get; set; }
        [DataMember]
        public Dictionary<string, string> DesignSettings { get; set; }
        //[DataMember]
        //public string Sql { get; set; }
        [IgnoreDataMember]
        public List<ChartDataGeneratorAggregateColumn> Columns { get; set; }
        [DataMember]
        public List<string> JoinClauses { get; set; }
        [DataMember]
        public ChartDataGeneratorAggregateFunctions Function { get; set; }
        [DataMember]
        public string Text { get; set; }
        [DataMember]
        public double? Credit { get; set; }
        [DataMember]
        public double? Constant { get; set; }

        /// <summary>
        /// Function_Text Property
        /// </summary>
        [IgnoreDataMember]
        public string Function_Text
        {
            get { return Constants.Enum_GetText(Function); }
        }

        public override string ToString()
        {
            return (Function == ChartDataGeneratorAggregateFunctions.Count) ? string.Format("{0}: {1}", Id, Function_Text) : string.Format("{0}: {1} - {2}", Id, Function_Text, Text);
        }
    }
}
